// import request from '../utils/request';
import { defHttp as request } from '/@/utils/http/axios';
import { handleDownloadFile } from './export';

// 用户管理列表
export const GetUserList = (params) => {
  return request.post({
    url: `/user/queryUserOrg`,
    data: params,
  });
};

// 添加用户
export const AddUser = (params) => {
  return request.post({
    url: `/user/addUser`,
    data: params,
  });
};
// 删除用户
export const DeleteUsers = (params) => {
  return request.post({
    url: `/user/revokeOrg`,
    data: params,
  });
};
// 授权管理员
export const AssignAdmin = (params) => {
  return request.post({
    url: `/user/grantAdmin`,
    data: params,
  });
};
// 删除管理员
export const DeleteAdmin = (params) => {
  return request.post({
    url: `/user/revokeAdmin`,
    data: params,
  });
};

// 锁定用户
export const LockUser = (data) => {
  return request.post({
    url: `/user/updateLock`,
    data,
  });
};

// 解锁用户
export const UnlockUser = (data) => {
  return request.post({
    url: `/user/updateLock`,
    data,
  });
};

export const EditUsers = (params) => {
  return request.post({
    url: `/user/updateUser`,
    data: params,
  });
};

// 查询所有组信息
export const EditGroupName = (params) => {
  return request.post({
    url: `/group/modifyGroup`,
    data: params,
  });
};

// update用户的角色信息
export const updateUserRole = (p) => {
  return request.post({
    url: `/user/grantRole`,
    data: p,
  });
};
// 查询数据权限列表
export const getDataPermissionList = (p) => {
  return request.post({
    url: `/dataPermission/queryDataPermissionByClient`,
    data: p,
  });
};
// update用户的数据权限
export const updateUserDataPermission = (p) => {
  return request.post({
    url: `/clientUser/grantUserDataPermissionByClient`,
    data: p,
  });
};

// 查询组及组下的用户角色权限信息
export const GetGroupByGroupId = (params) => {
  return request.post({
    url: `/group/queryGroupByGroupId`,
    data: params,
  });
};

export const queryAllUserAndSysOrg = (p) => {
  return request.post({
    url: '/user/queryUserOrgNot',
    data: p,
  });
};

export const getAccessableAppByToken = (p) => {
  return request.post({
    url: '/oauth-client/queryClient',
    data: p,
  });
};

export const downloadExcal = (data) => handleDownloadFile('user/download', data, null, 'POST');

// 查询行级权限列表
export const queryBus = () => {
  return request.post({
    url: `/bus/data/queryBus`,
  });
};
// 查询用户的行级权限
export const queryBusDataPermission = (p) => {
  return request.post({
    url: `/bus/row/data/permission/queryBusDataPermission`,
    data: p,
  });
};
// update用户的行级权限
export const grantBusDataPermission = (p) => {
  return request.post({
    url: `/bus/row/data/permission/grantBusDataPermission`,
    data: p,
  });
};

// 查询资源权限列表
export const queryBusCategory = () => {
  return request.post({
    url: `/bus/category/queryBusCategory`,
  });
};
// 查询用户的资源权限
export const queryBusResourceDataPermission = (p) => {
  return request.post({
    url: `/bus/resource/data/permission/queryBusResourceDataPermission`,
    data: p,
  });
};
// update用户的资源权限
export const grantBusResourceDataPermission = (p) => {
  return request.post({
    url: `/bus/resource/data/permission/grantBusResourceDataPermission`,
    data: p,
  });
};